package cn.tedu.system.base.response;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.awt.image.Kernel;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class JsonResult {
    @ApiModelProperty(value = "内部状态码", required = true)
    private Integer code;
    @ApiModelProperty(value = "提示消息", required = true)
    private String message;
    @ApiModelProperty(value = "数据")
    private Object data;

    public JsonResult(StatusCode resultCode) {
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
    }

    public JsonResult(StatusCode resultCode, Object data) {
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
        this.data = data;
    }

    public static JsonResult error(String 商品ID不能为空) {
        return new JsonResult(StatusCode.ERROR, 商品ID不能为空);
    }

    public static JsonResult ok(Object data){
        return new JsonResult(StatusCode.SUCCESS,data);
    }
    public static JsonResult ok(){
        return new JsonResult(StatusCode.SUCCESS);
    }

    @Override
    public String toString() {
        return "JsonResult{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}

